function [s_hat,signal] = cyclic41_detector(h,r,rho,nt,nr,r_previous)

r=r*sqrt(nt/rho);
r_previous=r_previous*sqrt(nt/rho);


z=transpose(r)*transpose(r_previous)';

%s_hat(1)=bin2qpsk(qpsk2bin(z(1,1) + conj(z(2,2))));
%s_hat(2)=bin2qpsk(qpsk2bin(z(1,2) - conj(z(2,1))));

g=[exp(-pi*j/2) 0; 0 exp(-pi*(j/2))];

for k=1:4
	residue(k)=sum(sum(abs(z-g^(k-1))));
end
[minim,index]=min(residue);

signal(1)=mod(index-1,2);
signal(2)=floor((index-1)/2);
s_hat=bin2qpsk(signal);
